//
//  MineViewController.m
//  AutoHome
//
//  Created by Flying meat on 9/11/15.
//  Copyright (c) 2015 CaoFeng. All rights reserved.
//

#import "MineViewController.h"
#import "MyCell.h"
@interface MineViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray *_titleArray;
    NSArray *_picArray;
    NSArray *_buttonNameArray;
    NSArray *_buttonPicArray;
}
@property (nonatomic,strong) UIView *headView;
@property (weak, nonatomic) IBOutlet UITableView *myTableView;
@property (nonatomic,strong) UILabel *headLabel;

@end

@implementation MineViewController
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        
        _titleArray=[[NSArray alloc]init];
    
        _picArray=[[NSArray alloc]init];
        
        _buttonNameArray=[[NSArray alloc]init];
        
        _buttonPicArray=[[NSArray alloc]init];
        
        _buttonPicArray=@[@"me_person.png",@"me_qq.png",@"me_weibo.png"];
        _buttonNameArray=@[@"账号登陆",@"QQ登陆",@"微博登陆"];
        
       
        
        
        
        _picArray=@[@[@"me_favourite.png",@"me_history.png",@"me_draft.png"],@[@"me_setting.png"]];
        
        _titleArray=@[@[@"我的收藏",@"浏览历史",@"草稿箱"],@[@"设置"]];
    
    
    
    
    }
    return self;
}




- (void)viewDidLoad {
    [super viewDidLoad];
 
    [self setView];
}

-(void)setView
{
    
    
    self.view.backgroundColor=[UIColor whiteColor];
    self.headView=[[UIView alloc]initWithFrame:CGRectMake(0, 64, 320, 150)];
    self.headView.backgroundColor=[UIColor whiteColor];
    self.myTableView.tableHeaderView=self.headView;
    self.headLabel=[[UILabel alloc]initWithFrame:CGRectMake(90, 20,150, 40)];
    self.headLabel.text=@"立即登录,更多体验";
    self.headLabel.textColor=[UIColor grayColor];
    [self.headView addSubview:self.headLabel];
    
    
    for (int i=0; i<3; i++) {
        UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
        button.frame=CGRectMake(100*i+10, 70, 100, 60);
        [button setImage:[UIImage imageNamed:_buttonPicArray[i]] forState:UIControlStateNormal];

        UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(100*i+35, 120, 80, 20)];
        label.font=[UIFont systemFontOfSize:13];
        label.text=_buttonNameArray[i];
        label.textColor=[UIColor grayColor];
        [self.headView addSubview:label];
        [self.headView addSubview:button];
        
    }
    
    
    
    
}

- (IBAction)nightAndMorning:(id)sender {
}



#pragma mark -UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSArray *array=_titleArray[section];
    
    
    return array.count;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return _titleArray.count;
    
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    MyCell*cell=[tableView dequeueReusableCellWithIdentifier:@"MyCell"];
    
    cell.accessoryType=UITableViewCellStyleValue1;
    NSArray *array=_titleArray[indexPath.section];
    cell.textLabel.text=array[indexPath.row];
    
    NSArray *picarry=_picArray[indexPath.section];
    cell.imageView.image=[UIImage imageNamed:picarry[indexPath.row]];
    
    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    
    return 20;
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
